package com.test.loop;

public class BreakAndContinueDemo9 {
    public static void main(String[] args) {
        //目标：break和continue关键字的使用
        breaktest();
        System.out.println();
        continuetest();
    }

    public static void breaktest() {
        //需求：打印1-10之间的整数，当打印到5时，结束循环
        for (int i = 1; i <= 10; i++) {
            if (i == 5) {
                break;
            }
            System.out.print(i);
        }
    }

    public static void continuetest() {
        //需求：打印1-10之间的整数，当打印到5时，跳过5，继续打印后面的数字
        for (int i = 1; i <= 10; i++) {
            if (i == 5) {
                continue;
            }
            System.out.print(i);
        }
    }
}



